<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $data = json_decode(file_get_contents('php://input'), true);
    $filename = $data['filename'];
    $note = $data['note'];

    $notesFile = 'notes.json';
    $notes = file_exists($notesFile) ? json_decode(file_get_contents($notesFile), true) : [];

    // 保存或更新备注
    $notes[$filename] = $note;
    file_put_contents($notesFile, json_encode($notes));

    // 返回成功响应
    echo json_encode(['status' => 'success']);
}
?>
